<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<style type="text/css">
.dateWidth1{
   width:195px;
}
.select_width{
   width:130px;
}
</style>
<x:parse xml="${param.xmlstr}" var="xmlData" />

<table class="t_css" width="100%" border="0" cellpadding="0" id="basicInfo"
	cellspacing="1">
	<tr>
		<td   colspan="6" class="t_bar2">基本信息</td>
		
	</tr>
	<tr>
		<td   align="right"><span class="color_red">*</span>项目名称：</td>
		<td  colspan="5">
			<input id="zh_title" name="proposal/zh_title" label="项目名称" type="text" required class="input_css required "  style="width: 725px;" maxlength="100" value="<x:out select="$xmlData/data/proposal/zh_title" />"/> 
		</td>
	</tr> 
	
	<tr>
	   <td  align="right" ><span class="color_red">*</span>开始日期：</td>
		<td colspan="2">
			<c:set var="start_date"><x:out select="$xmlData/data/proposal/start_date" /></c:set>
			<cpt:date id="start_date" name="proposal/start_date" value="${start_date}" className=" required date  dateCompare:end_date" label="开始日期" ></cpt:date> 
		</td>
		<td  align="right" ><span class="color_red">*</span>结束时间：</td>
		<td colspan="2">
			<c:set var="end_date"><x:out select="$xmlData/data/proposal/end_date" /></c:set>
			<cpt:date id="end_date" name="proposal/end_date" className=" required date" label="结束时间"  value="${end_date}" ></cpt:date> 
		</td>
	</tr>
	<tr>
	<td align="right"><span class="color_red">*</span>采购项目类别：</td>
		<td nowrap  colspan="5" valign="middle">
		<label> <input type="radio" class="do " id="purchase_01" style="vertical-align: middle;" name="purchase" label="产品采购" value="01" /><span style="vertical-align: middle;">产品采购</span></label> 
		<label> <input type="radio" class="do " id="purchase_02" style="vertical-align: middle;" name="purchase" label="服务采购" value="02" /><span style="vertical-align: middle;">服务采购</span></label> 
		<input type="hidden" name="proposal/purchase_value" id="purchase_value" class="required" value="<x:out select="$xmlData/data/proposal/purchase_value" />" label="采购项目类别" /> 
		<input type="hidden" name="proposal/purchase_name" id="purchase_name" value="<x:out select="$xmlData/data/proposal/purchase_name" />" label="采购项目类别" /></td>
	</tr>
	
	<tr>
	    <td  align="right" nowrap><span class="color_red">*</span>申报日期：</td>
		<td colspan="2">
			<c:set var="submit_date"><x:out select="$xmlData/data/proposal/submit_date" /></c:set>
			<cpt:date id="submit_date" name="proposal/submit_date" value="${submit_date}" className=" required date" label="申报日期"></cpt:date> 
		</td>
		<td>&nbsp;</td>
		<td colspan="2">&nbsp;</td>
	
	</tr>
	<tr>
		<td   colspan="6" class="t_bar2">上年度主要经营状况</td>
	</tr>
	<tr >
	<td align="right">销售收入（万元）：</td>
	<td>
	<input type="hidden" id="sell1" name="invests/sell_2011" value="<x:out select="$xmlData/data/organization/finances/finance[@sequence_no='3']/income" />"/>
	<span name="invests/sell" id="sell2"><x:out select="$xmlData/data/organization/finances/finance[@sequence_no='5']/income" /></span></td>
	<td align="right">同比增加（万元）：</td>
	<td><span name="invests/add1" id="add1"><x:out select="$xmlData/data/invests/add1" /></span></td>
	<td align="right">增幅%：</td>
	<td><span name="invests/increase1" id="increase1"><x:out select="$xmlData/data/invests/increase1" /></span></td>
	</tr>
	<tr >
	<td align="right">利润总额（万元）：</td>
	<td>
	<input type="hidden" id="profit1" name="invests/profit_2011" value="<x:out select="$xmlData/data/organization/finances/finance[@sequence_no='3']/proft_total" />"/>
	<span name="invests/profit" id="profit2"><x:out select="$xmlData/data/organization/finances/finance[@sequence_no='5']/proft_total" /></span></td>
	<td align="right">同比增加（万元）：</td>
	<td><span name="invests/add2" id="add2"><x:out select="$xmlData/data/invests/add2" /></span></td>
	<td align="right">增幅%：</td>
	<td><span name="invests/increase2" id="increase2"><x:out select="$xmlData/data/invests/increase2" /></span></td>
	</tr>
	<tr >
	<td align="right">税收总额（万元）：</td>
	<td>
	<input type="hidden" id="tax1" name="invests/tax_2011" value="<x:out select="$xmlData/data/organization/finances/finance[@sequence_no='3']/fax" />"/>
	<span name="invests/tax" id="tax2"><x:out select="$xmlData/data/organization/finances/finance[@sequence_no='5']/fax" /></span></td>
	<td align="right">同比增加（万元）：</td>
	<td><span name="invests/add3" id="add3"><x:out select="$xmlData/data/invests/add3" /></span></td>
	<td align="right">增幅%：</td>
	<td><span name="invests/increase3" id="increase3"><x:out select="$xmlData/data/invests/increase3" /></span></td>
	</tr>
	<tr>
		<td   colspan="6" class="t_bar2"><span class="color_red">*</span>近两年本地采购情况</td>
		
	</tr>
	<tr>
	<td align="right">2011年本地采购总额（万元）：</td>
	<td><input type="text" style="text-align: right; width: 80%" name="proposal/purchase1" label="2011年本地采购总额" class="required"  value="<x:out select="$xmlData/data/proposal/purchase1" />" onfocus="InitInput.setNumber(this,9,4,2)" /></td>
	<td align="right">增幅%：</td>
	<td><input type="text" style="text-align: right; width: 80%" name="proposal/purchase1_add" label="2011年本地采购总额-->增幅" class="required"  value="<x:out select="$xmlData/data/proposal/purchase1_add" />" onfocus="InitInput.setNumber(this,9,2,2,null,true)" /></td>
	<td align="right">本地采购率%：</td>
	<td><input type="text" style="text-align: right; width: 80%" name="proposal/purchase1_total" label="2011年本地采购总额-->本地采购率" class="required"  value="<x:out select="$xmlData/data/proposal/purchase1_total" />" onfocus="InitInput.setNumber(this,9,2,2,null,true)" /></td>
	</tr>
	<tr>
	<td align="right">2012年本地采购总额（万元）：</td>
	<td><input type="text" style="text-align: right; width: 80%" name="proposal/purchase2" label="2012年本地采购总额" class="required"  value="<x:out select="$xmlData/data/proposal/purchase2" />" onfocus="InitInput.setNumber(this,9,4,2)" /></td>
	<td align="right">增幅%：</td>
	<td><input type="text" style="text-align: right; width: 80%" name="proposal/purchase2_add" label="2012年本地采购总额-->增幅" class="required"  value="<x:out select="$xmlData/data/proposal/purchase2_add" />" onfocus="InitInput.setNumber(this,9,2,2,null,true)" /></td>
	<td align="right">本地采购率%：</td>
	<td><input type="text" style="text-align: right; width: 80%" name="proposal/purchase2_total" label="2012年本地采购总额-->本地采购率" class="required"  value="<x:out select="$xmlData/data/proposal/purchase2_total" />" onfocus="InitInput.setNumber(this,9,2,2,null,true)" /></td>
	</tr>
	<tr>
		<td   colspan="6" class="t_bar2"><span class="color_red">*</span>本地主要采购单位信息（行次可添加）</td>
	</tr>
	</table>
<table class="t_css" width="100%" border="0" cellpadding="0" cellspacing="1" id="tblPurchases">
   <thead >
	<tr name="externTr">
	   	<th class="TblHead" align="center"  width="5%">选择</th>
		<th class="TblHead" align="center"  width="5%">序号</th>
		<th class="TblHead" align="center" width="90%" >本地主要采购单位信息</th>
	</tr>
	</thead>
			<tbody id="tab">
					<tr style="display:none" align="center" name="externTr">
						<td align="center">&nbsp;<input type="radio" class="radiobutton" name="selPurchases" ></td>
						<td align="center">&nbsp;<span name="purchases|purchase[0]@seq_no" >[index]</span></td>
						<td>
						<table cellpadding="0" class="table01" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
						<tr>
				           <td align="right">单位名称：</td>
				           <td colspan="3"><input name="purchases|purchase[0]|org_name" label="单位名称" type="text"  class="input_css required" style="width: 650px;" maxlength="100" value="" /></td>
		                </tr>
						<tr>
							<td align="right">单位地址：</td>
							<td colspan="3"><input name="purchases|purchase[0]|address" label="单位地址" type="text" required class="input_css required" style="width: 650px;" maxlength="100" value="" /></td>
						</tr>
						<tr>
							<td width="14%" align="right">注册类型：</td>
							<td width="38%" align="left" colspan="1">
							 <cpt:tree key="nature_type" cacheable="false" className="hn_iuput_kuang gray" readonly="true" value="${nature}" label="注册类型"
							  id="nature[index]" showPattern="current" shieldPattern="0" topCheckbox="false" onClick="initTreeValue" /> 
							 <input type="hidden" id="nature[index]_code" name="purchases|purchase[0]|nature_code" class="required" label="注册类型" value="" /> 
							<input type="hidden" id="nature[index]_name" name="purchases|purchase[0]|nature_name" value="" /></td>
							<td align="right">组织机构代码：</td>
							<td><input name="purchases|purchase[0]|org_no" label="组织机构代码" type="text" class="input_css orgCard required" maxlength="20" value="" /></td>
						</tr>
						<tr>
							<td align="right" nowrap>年采购额（万元）：</td>
							<td>
							<input name="purchases|purchase[0]|money" label="年采购额" type="text" class="input_css required" style="text-align: right" onfocus="InitInput.setNumber(this,9,4,2)"  maxlength="20" value="" /></td>
							<td align="right" nowrap>采购额占总采购量比例%：</td>
							<td><input name="purchases|purchase[0]|money_pre" label="采购额占总采购量比例" type="text" class="input_css required" style="text-align: right" onfocus="InitInput.setNumber(this,9,4,2)" maxlength="20" value="" /></td>
						</tr>
						<tr>
							<td align="right">联系人：</td>
							<td>
							<input name="purchases|purchase[0]|lxr_name" label="联系人姓名" type="text" class="input_css required" maxlength="20" value="" /></td>
							<td align="right">电话：</td>
							<td><input name="purchases|purchase[0]|lxr_tel" label="联系人电话" type="text" class="input_css required" maxlength="20" value="" /></td>
						</tr>
						</table>
						</td>
					</tr>
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/purchases/purchase" var="purchase">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr align="center" name="externTr">
						<td align="center">&nbsp;<input type="radio" class="radiobutton" name="selPurchases" ></td>
						<td align="center">&nbsp;<span name="purchases/purchase[${flag}${index}]@seq_no" ><x:out select="$purchase/@seq_no"/></span></td>
						<td>
						<table cellpadding="0" class="table01" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
						<tr>
				           <td align="right">单位名称：</td>
				           <td colspan="3"><input name="purchases/purchase[${flag}${index}]/org_name" label="单位名称" type="text"  class="input_css required" style="width: 650px;" maxlength="100" value="<x:out select="$purchase/org_name" />" /></td>
		                </tr>
						<tr>
							<td align="right">单位地址：</td>
							<td colspan="3"><input name="purchases/purchase[${flag}${index}]/address" label="单位地址" type="text" required class="input_css required" style="width: 650px;" maxlength="100" value="<x:out select="$purchase/address" />" /></td>
						</tr>
						<tr>
							<td width="14%" align="right">注册类型：</td>
							<td width="38%" align="left" colspan="1">
							<c:set var="nature">{'id':'<x:out select="$purchase/nature_code" />','name':'<x:out select="$purchase/nature_name" />'}</c:set>
							 <cpt:tree key="nature_type" cacheable="false" className="hn_iuput_kuang gray" readonly="true" value="${nature}" label="注册类型"
							  id="nature${flag}${index}"  showPattern="current" shieldPattern="0" topCheckbox="false" onClick="initTreeValue" /> 
							 <input type="hidden" id="nature${flag}${index}_code" name="purchases/purchase[${flag}${index}]/nature_code" class="required" label="注册类型" value="<x:out select="$purchase/nature_code" />" /> 
							<input type="hidden" id="nature${flag}${index}_name" name="purchases/purchase[${flag}${index}]/nature_name" value="<x:out select="$purchase/nature_name" />" /></td>
							<td align="right">组织机构代码：</td>
							<td><input name="purchases/purchase[${flag}${index}]/org_no" label="组织机构代码" type="text" class="input_css orgCard required" maxlength="20" value="<x:out select="$purchase/org_no" />" /></td>
						</tr>
						<tr>
							<td align="right" nowrap>年采购额（万元）：</td>
							<td>
							<input name="purchases/purchase[${flag}${index}]/money" label="年采购额" type="text" class="input_css required" style="text-align: right" onfocus="InitInput.setNumber(this,9,4,2)"  maxlength="20" value="<x:out select="$purchase/money" />" /></td>
							<td align="right" nowrap>采购额占总采购量比例%：</td>
							<td><input name="purchases/purchase[${flag}${index}]/money_pre" label="采购额占总采购量比例" type="text" class="input_css required"  style="text-align: right" onfocus="InitInput.setNumber(this,9,4,2)" maxlength="20" value="<x:out select="$purchase/money_pre" />" /></td>
						</tr>
						<tr>
							<td align="right">联系人：</td>
							<td>
							<input name="purchases/purchase[${flag}${index}]/lxr_name" label="联系人姓名" type="text" class="input_css required" maxlength="20" value="<x:out select="$purchase/lxr_name" />" /></td>
							<td align="right">电话：</td>
							<td><input name="purchases/purchase[${flag}${index}]/lxr_tel" label="联系人电话" type="text" class="input_css required" maxlength="20" value="<x:out select="$purchase/lxr_tel" />" /></td>
						</tr>
						</table>
						</td>
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
				</tbody>
					</table>
					<table width="98%" align="center">
					<tr ><td>
					<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('tblPurchases',20,'本地主要采购单位信息最多只能填写20条')){addNewRow('tblPurchases');showDateTag('tblPurchases');}try{top.resizeFrame();}catch(e){};">
					<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev('tblPurchases','selPurchases')">
					<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext('tblPurchases','selPurchases')">
					<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('tblPurchases','本地主要采购单位信息');">
					</td></tr>
					</table>	
	<table class="t_css" width="100%" border="0" cellpadding="0" id="basicInfo1"
	cellspacing="1">
	<tr>
		<td   colspan="6" class="t_bar2">申请项目资金情况</td>
		
	</tr>
	<tr>
	<td  align="right"  >项目类别：</td>
	<td  colspan="5"><x:out select="$xmlData/data/proposal/grant_name" />
	</td>
	 
	</tr>
	<tr>
		<td  align="right"><span class="color_red">*</span>申请金额（万元）：</td>
		<td  colspan="2" >
		<input  name="proposal/source_apply" id="source_apply"   label="申请金额" type="text"  class="input_css required" style="text-align: right" onfocus="InitInput.setNumber(this,9,4,2)"  value="<x:out select="$xmlData/data/proposal/source_apply" />"/> 
		</td>
		<td  align="right"  >项目核准或备案文号：</td>
		<td  colspan="2"  ><span  name="proposal/project_approval">无</span>
	</tr>
	<tr>
	<td  align="right">支持方式：</td>
	<td  colspan="2" >
		<span name="proposal/sponsor_category"><x:out select="$xmlData/data/proposal/sponsor_category" /></span> 
	</td>
	<td  align="right">资金级次：</td>
    <td colspan="2" >
	    <span  name="proposal/fund_level">市级</span>
	</td>
	</tr>
	<tr>
	<td  align="right" nowrap>归口管理部门：</td>
		<td  colspan="2" ><span name="proposal/org_name">无锡市经济和信息化委员会</span> </td>
	    <td  align="right">管理类别：</td>
		<td colspan="2" >
		<span name="proposal/manage_category"><x:out select="$xmlData/data/proposal/manage_category" /></span>
		</td>
		
	</tr>
	<tr>
		<td  align="right" nowrap><span class="color_red">*</span>项目所属产业：</td>
		<td nowrap colspan="5">
			<c:set var="industry"><x:out select="$xmlData/data/proposal/industry_value" /></c:set>
			<cpt:checkbox key="industry" name="industry" repeatColumn="5" style="border: 0px; padding: 0px; margin: 0px;float:left;"></cpt:checkbox>
			<input type="hidden" id="industry_value" name="proposal/industry_value" class="required" value="${industry}" label="项目所属产业">
			<input type="hidden" name="proposal/industry_name" value="<x:out select="$xmlData/data/proposal/industry_name" />">
		</td>
	</tr>
	<tr>
	    <td  align="right">功能分类：</td>
		<td  colspan="5">
		<span name="proposal/grant_function"><x:out select="$xmlData/data/proposal/grant_function" /></span>
		</td>
		
	</tr>
	</table>
	<table  width="100%" border="0" cellpadding="0" cellspacing="1">
	<tr>
		<td    class="t_bar2">申请资助依据条款</td>
		
	</tr>
	<tr>
		<td >
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<span name="proposal/policy_foundation"><x:out select="$xmlData/data/proposal/policy_foundation" /></span> 
		</td>
	</tr>
</table>
<br/>
<table class="t_css" width="100%" border="0" cellpadding="0" id="basicInfo"
	cellspacing="1">
	<tr>
		<td class="t_bar2" colspan="8">人员信息</td>
		
	</tr>
<tr>
		<td  align="right"><span class="color_red">*</span>项目联系人：</td>
		<td  >
			<input  name="proposal/contact_psn_cname" label="项目联系人" type="text" required class="input_css required"   maxlength="20" value="<x:out select="$xmlData/data/proposal/contact_psn_cname" />"/> 
		</td>
		<td  align="right"><span class="color_red">*</span>联系电话：</td>
		<td  >
			<input  name="proposal/contact_psn_tel" label="联系电话" type="text" required class="input_css required"   maxlength="20" value="<x:out select="$xmlData/data/proposal/contact_psn_tel" />"/> 
		</td>
		<td  align="right"><span class="color_red">*</span>联系手机：</td>
		<td  >
			<input  name="proposal/contact_psn_mobile" label="联系手机" type="text" required maxlength="11" required class="input_css required mobile"   maxlength="20" value="<x:out select="$xmlData/data/proposal/contact_psn_mobile" />"/> 
		</td>
		<td  align="right"><span class="color_red">*</span>电子邮箱：</td>
		<td  >
			<input  name="proposal/contact_psn_email" label="电子邮箱" type="text" required class="input_css required email"   maxlength="50" value="<x:out select="$xmlData/data/proposal/contact_psn_email" />"/> 
		</td>
	</tr>
	
	<tr>
		<td  align="right">项目负责人：</td>
		<td>
			<input  name="proposal/fzr_psncode" type="hidden" required class="input_css "   maxlength="20" value="<x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/psn_code" />"/> 
		    
		    <span name="proposal/fzr_psnname" ><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/zh_name" /></span>
		    <c:set var="psnCode"><x:out select="$xmlData/data/proposal/psn_code" /></c:set>
		    <security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
				<span id="personSelect">
				<input type="button" class="button_02" style="height: 25px; padding: 1px;" id="selectPsn" value="设置">
				<cpt:personSelect key="personSelect"  addRole="3"  psnCode="${psnCode}" callback="selectPsnCall" bindEvent="click" bindObject="selectPsn" title="设置项目负责人" fltFile="personSelector.ftl"></cpt:personSelect>
				</span>
			</security:authorize>
		</td>
		<security:authorize ifNotGranted="A_DAILU_PROPOSAL"> 
		<td  align="right">联系电话：</td>
		<td  >
		<span name="proposal/fzr_tel"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/tel_work" /></span>
		</td>
		<td  align="right">联系手机：</td>
		<td  >
		<span name="proposal/fzr_mobile"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/mobile" /></span>
		</td>
		</security:authorize>
		<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
		<td  align="right"><span class="color_red">*</span>联系电话：</td>
		<td  >
		<input name="proposal/fzr_tel" label="项目负责人联系电话" type="text" required  class="input_css required"  onchange="synFzrMsg(1)"  maxlength="50"  value="<x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/tel_work" />"/>
		</td>
		<td  align="right"><span class="color_red">*</span>联系手机：</td>
		<td  >
		<input name="proposal/fzr_mobile" label="项目负责人联系手机" type="text" onchange="synFzrMsg(1)" onfocus="InitInput.setNumber(this,11,0,0)"  maxlength="11"  class="input_css required mobile"   value="<x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/mobile" />"/>
		</td>
		</security:authorize>
		<td  align="right">电子邮箱：</td>
		<td  >
		<span name="proposal/fzr_mail"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/email" /></span>
		</td>
	</tr>
</table>


<script type="text/javascript">
    $(function(){
    	$("#sell2").text($("#sell2").text().replace(new RegExp("\,","g"), ""));
    	$("#add1").text(formatVal($("#sell2").text().replace(new RegExp("\,","g"), "")-$("#sell1").val().replace(new RegExp("\,","g"), "")));
    	if($("#sell1").val()==0 || $("#sell1").val() == ''){
			$("#increase1").text("0.00");
		}else{
    	$("#increase1").text(formatVal(($("#sell2").text().replace(new RegExp("\,","g"), "")-$("#sell1").val().replace(new RegExp("\,","g"), ""))*100/Math.abs($("#sell1").val().replace(new RegExp("\,","g"), ""))));
		}
    	$("#profit2").text($("#profit2").text().replace(new RegExp("\,","g"), ""));
		$("#add2").text(formatVal($("#profit2").text().replace(new RegExp("\,","g"), "")-$("#profit1").val().replace(new RegExp("\,","g"), "")));
		if($("#profit1").val()==0 || $("#profit1").val() == ''){
			$("#increase2").text("0.00");
		}else{
		$("#increase2").text(formatVal(($("#profit2").text().replace(new RegExp("\,","g"), "")-$("#profit1").val().replace(new RegExp("\,","g"), ""))*100/Math.abs($("#profit1").val().replace(new RegExp("\,","g"), ""))));
		}
		$("#tax2").text($("#tax2").text().replace(new RegExp("\,","g"), ""));
		$("#add3").text(formatVal($("#tax2").text().replace(new RegExp("\,","g"), "")-$("#tax1").val().replace(new RegExp("\,","g"), "")));
		if($("#tax1").val()==0 || $("#tax1").val() == ''){
			$("#increase1").text("0.00");
		}else{
		$("#increase3").text(formatVal(($("#tax2").text().replace(new RegExp("\,","g"), "")-$("#tax1").val().replace(new RegExp("\,","g"), ""))*100/Math.abs($("#tax1").val().replace(new RegExp("\,","g"), ""))));
		}
    });
    
    
    /**
     * 增加一行
     * @param tableId表格Id
     * @param radioId
     * @param nNewRowPosition
     * @param startRowIndex
     */
    function addNewRowDeal(table)
    {
    	if(table.attr("id")=='tblPurchases'){
    		var maxLinNum=table.find("tr[name='externTr']").length-2;;//获得行数，减去表头和隐藏行
    		var lineNum=""+(maxLinNum+1);
    		
    		var addHtml=table.find("tr[name='externTr']")[1].innerHTML;//获得隐藏行的html,查找第二行
    		addHtml=addHtml.replace(/\[index\]/g,lineNum);
    		lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
    		if (lineNum.length==1)//如果是个位数，前面补0
    			lineNum="0"+lineNum;
    		addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
    		addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
    		
    		table.append("<tr name='externTr'>"+addHtml+"</tr>");//将html增加到最后
    	}else{
    		var maxLinNum=table.find("tr").length-2;;//获得行数，减去表头和隐藏行
    		var lineNum=""+(maxLinNum+1);
    		
    		var addHtml=table.find("tr")[1].innerHTML;//获得隐藏行的html,查找第二行
    		addHtml=addHtml.replace(/\[index\]/g,lineNum);
    		lineNum = (parseInt(lineNum, 10)-1).toString();//2011.12.13 行下标比行号小1(隐藏行下标[0]，第一行下标[00])
    		if (lineNum.length==1)//如果是个位数，前面补0
    			lineNum="0"+lineNum;
    		addHtml=addHtml.replace(/\[0\]/g,"["+lineNum+"]");//替换html中行号
    		addHtml=addHtml.replace(/\|/g,"/");//替换html中节点/的代替符"|"
    		
    		table.append("<tr >"+addHtml+"</tr>");//将html增加到最后
    	}
    }
    /**
     * 上移行
     * @param tblId
     * @returns {Boolean}
     */
    function movePrev(tblId,selName) {

    	if (!selName)
    		selName = "";
    	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
    		scmWarn(irisNotes.prevWarn);
    		return false;
    	}
    	if ($("#" + tblId + " tr[name='externTr']").length <= 2)
    		return false;
    	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
    			.parents("tr").first();// 取得被选中的行
    	var trPrev = trChecked.prev();// 取得上一行
    	var index = trChecked.get(0).rowIndex;// 获得行号
    	if (index <= 2) {// 如果是第一行
    		scmWarn(irisNotes.tabelMoveWarn1);
    		return false;
    	}
    	//trChecked.remove();
    	trPrev.before(trChecked);
    	trChecked.find(":radio[name*='" + selName + "']").attr("checked", 'true');
    	refreshRowINdex(tblId);
    }

    /**
     * 下移行
     * @param tblId
     * @returns {Boolean}
     */
    function moveNext(tblId,selName) {
    	if (!selName)
    		selName = "";
    	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
    		scmWarn(irisNotes.nextWarn);
    		return false;
    	}
    	if ($("#" + tblId + " tr[name='externTr']").length <= 2) {
    		return false;
    	}
    	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
    			.parents("tr").first();// 取得被选中的行
    	var trNext = trChecked.next();
    	var index = trChecked.get(0).rowIndex;// 获得行号
    	if (index == $("#" + tblId + " tr[name='externTr']").length - 1) {// 如果是第一行
    		scmWarn(irisNotes.tabelMoveWarn2);
    		return false;
    	}
    	//trChecked.remove();
    	trNext.after(trChecked);
    	trChecked.find(":radio[name*='" + selName + "']").attr("checked", "true");
    	refreshRowINdex(tblId);
    }
    /**
     * 重新计算行号
     * @param tblId
     */
    function refreshRowINdex(tblId){
    	 //重新计算行号

    	if(tblId=='tblPurchases'){
    	  $("#"+tblId+" tr[name='externTr']").each(function(){
    		  
    		   var seq=$(this).get(0).rowIndex;//获得行数
    		   if(seq>1){//如果有行  显示时display行不计入类，故只减1
    			   
    			   seq=seq-1;
    			   var seq_no=$(this).find("[name$='seq_no']");
    			   if(seq_no.is("span"))
    				   seq_no.html(seq);
    			   else
    				   seq_no.val(seq);
    			   
    			   seq=""+(seq-1);
    			   if(seq.length==1)
    				   seq="0"+seq;
    			  //替换相应的name参数的seq
    			  $(this).find("input,span,textarea,select").each(function(){
    				   var name=$(this).attr("name");
    				   if(name!=null&&name!=""){
    					   name=name.replace(/\[\d*\]/g,"["+seq+"]");
    					   $(this).attr("name",name);
    				   }
    				   var id=$(this).attr("id");
    				   if(id!=null&&id!=""){
    					   id=id.replace(/\[\d*\]/g,"["+seq+"]");
    					   $(this).attr("id",id);
    				   }
    				   var className=$(this).attr("class");
    				   if(className!=null&&className!=""){
    					   className=className.replace(/\[\d*\]/g,"["+seq+"]");
    					   $(this).attr("class",className);
    				   }
    			   });
    		   }
    		 }
    	  );
    	}else{
    		$("#"+tblId+" tr").each(function(){
    			  
    			   var seq=$(this).get(0).rowIndex;//获得行数
    			   if(seq>1){//如果有行  显示时display行不计入类，故只减1
    				   
    				   seq=seq-1;
    				   var seq_no=$(this).find("[name$='seq_no']");
    				   if(seq_no.is("span"))
    					   seq_no.html(seq);
    				   else
    					   seq_no.val(seq);
    				   
    				   seq=""+(seq-1);
    				   if(seq.length==1)
    					   seq="0"+seq;
    				  //替换相应的name参数的seq
    				  $(this).find("input,span,textarea,select").each(function(){
    					   var name=$(this).attr("name");
    					   if(name!=null&&name!=""){
    						   name=name.replace(/\[\d*\]/g,"["+seq+"]");
    						   $(this).attr("name",name);
    					   }
    					   var id=$(this).attr("id");
    					   if(id!=null&&id!=""){
    						   id=id.replace(/\[\d*\]/g,"["+seq+"]");
    						   $(this).attr("id",id);
    					   }
    					   var className=$(this).attr("class");
    					   if(className!=null&&className!=""){
    						   className=className.replace(/\[\d*\]/g,"["+seq+"]");
    						   $(this).attr("class",className);
    					   }
    				   });
    			   }
    			 }
    		  );
    	}
    }
    
    /**
     * 限制Table行数 
     * @param tableId表格id
     * @param max最大行数
     * @returns {Boolean}
     */
    function checkTabLimit(tableId,max,message)
    {
    	 if(tableId=='tblPurchases'){
    	var maxLinNum=$("#"+tableId+" tr[name='externTr']").length-2;
    		if(maxLinNum>=max)
    		{
    			scmWarn(message);
    			return false;
    		}
    	return true;
    	 }else{
    		 var maxLinNum=$("#"+tableId+" tr").length-2;
    			
    			if(maxLinNum>=max)
    			{
    				scmWarn(message);
    				return false;
    			}
    		return true;
    	 }
    }
     
     /**
 	 * 选择树设置隐藏域值 public.js中原函数不适用
 	 */
 	function initTreeValue(treeId, treeNode) {
 		
 		if (!(treeNode && treeNode.level > 0 || !treeNode.isParent) ) {
 			scmWarn($("#" + treeId).attr("label")
 					+ messageTip.researchAreaInvalidDisciplineCode);
 			if (treeNode.level == 0) {
 				$("#" + treeId).val("");
 				$("#" + treeId).parents("td").find(
 						"[name$='" + treeId + "_code'],[id$='" + treeId
 								+ "_code']").val("");
 				$("#" + treeId).parents("td").find(
 						"[name$='" + treeId + "_name'],[id$='" + treeId
 								+ "_name']").val("");
 			}
 			return false;
 		}
 		var oldval = $("#" + treeId).parents("td").find(
 				"[name$='" + treeId + "_code'],[id$='" + treeId + "_code']")
 				.val();
 		var oldname = $("#" + treeId).parents("td").find(
 				"[name$='" + treeId + "_name'],[id$='" + treeId + "_name']")
 				.val();
 		oldval = $.trim(oldval);
 		oldname = $.trim(oldname);
 		var str = treeNode.name;
 		var obj = treeNode.parentNode;
 		while (obj != null) {
 			str = obj.name + "-" + str;
 			obj = obj.parentNode;
 		}
 		if (treeId == 'impl_area') {

 			if (treeNode.checked) {
 				if (oldname != '')
 					oldname += ',';
 				if (oldval != '')
 					oldval += ',';
 				if(oldval.indexOf(treeNode.id)==-1)
 					$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val(oldval + treeNode.id);
 				if(oldname.indexOf(str)==-1){
 					$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val(oldname + str);
 					$("#" + treeId).parents("td").find("[name='" + treeId + "'],[id='" + treeId + "']").val(oldname + str);
 				}
 			} else {
 				$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val(("," + oldval).replace(',' + treeNode.id, '').substring(1));
 				$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val(("," + oldname).replace("," + str, '').substring(1));
 				$("#" + treeId).parents("td").find("[name='" + treeId + "'],[id='" + treeId + "']").val(("," + oldname).replace("," + str, '').substring(1));
 			}
 		} else {
 			$("#" + treeId).parents("td")
 					.find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val(treeNode.id);
 			$("#" + treeId).parents("td")
 					.find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val(str);
 		}

 	}
</script>